package org.springblade.tms.module.currencytype.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.tms.module.currencytype.base.CurrencyService;
import org.springblade.tms.module.currencytype.dto.TMCurrencyTypeDTO;
import org.springblade.tms.module.currencytype.entity.TMCurrencyType;
import org.springblade.tms.module.currencytype.vo.TMCurrencyTypeVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @projectName: BladeX
 * @package: org.springblade.tms.module.currencytype.controller
 * @className: CurrencyController
 * @author: yr
 * @description: 币别接口
 * @date: 2022/4/18 10:24
 */
@RestController
@RequestMapping("currencyType/currency")
@Api(value = "币别-yr", tags = "币别接口-yr")
public class CurrencyController {
	@Resource
	private CurrencyService currencyService;

	/**
	 * 查询币种
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "查询币种", notes = "传入currencyType")
	public R<IPage<TMCurrencyTypeVO>> list(TMCurrencyTypeDTO TMCurrencyType, Query query) {
		return currencyService.list(TMCurrencyType,query);
	}

	/**
	 * 新增或修改 币种
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "新增或修改", notes = "传入currencyType")
	public R<Boolean> submit(@Valid @RequestBody TMCurrencyType TMCurrencyType) {
		return R.status(currencyService.saveOrUpdate(TMCurrencyType));
	}

	/**
	 * 删除 币种
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "删除币种", notes = "传入ids")
	public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return currencyService.remove(Func.toLongList(ids));
	}
}
